package routes

import (
	"fmt"
	"net/http"

	utils "github.com/nchursin/formtgbot/api/utils"
	"github.com/nchursin/formtgbot/redis"
	structs "github.com/nchursin/formtgbot/structs"
	tg "github.com/nchursin/formtgbot/telegram"
)

func Response(w http.ResponseWriter, r *http.Request) {
	var parsedBody structs.Vacancy
	utils.ParseJson(r.Body, &parsedBody)
	fmt.Printf("Incoming request %s\n", parsedBody)

	redis.Store(&parsedBody)
	tg.GetBot().SendMessage(&parsedBody)

	fmt.Fprintf(w, "Logged")
}
